<template>
	<view class="">
		<view style="background: #fff;">
			<!-- nav_btn="back" -->
			<nav-bar :title="title"></nav-bar>
		</view>
		<view class=""
			style="margin-left: 32rpx;font-weight: 500;color: #000000;font-size: 40rpx;margin-top: 40rpx;margin-bottom: 60rpx;">
			添加人员
		</view>
		<view @click="clickList" class="flex align-center"
			style="background: #F4F5F9;border-radius: 16rpx 16rpx 16rpx 16rpx;margin: 0 32rpx;margin-top: 40rpx;padding: 32rpx 40rpx;">
			<view class="" style="font-size: 0;margin-right: 40rpx;">
				<image style="width: 60rpx;height: 60rpx;" src="./static/1.png" mode=""></image>
			</view>
			<view class="flex-1">
				<view class="" style="font-size: 32rpx;font-weight: 500;color: #000000;">
					邀请加入团队
				</view>
				<view class="" style="color: #666666;margin-top: 12rpx;font-size: 24rpx;">
					分享邀请码或邀请链接，用户扫码或复制邀请码进入小程序加入我的团队
				</view>
			</view>
			<view class="" style="font-size: 0;margin-left: 50rpx;">
				<image style="width: 14rpx;height: 20rpx;" src="./static/8.png" mode=""></image>
			</view>
		</view>
		<view v-if="identity==3||identity==5||identity==4" class="flex align-center" @click="goInvite"
			style="background: #F4F5F9;border-radius: 16rpx 16rpx 16rpx 16rpx;margin: 0 32rpx; margin-top: 40rpx;padding: 32rpx 40rpx;">
			<view class="" style="font-size: 0;margin-right: 40rpx;">
				<image style="width: 60rpx;height: 60rpx;" src="./static/2.png" mode=""></image>
			</view>
			<view class="flex-1">
				<view class="" style="font-size: 32rpx;font-weight: 500;color: #000000;">
					邀请店铺合伙人
				</view>
				<view class="" style="color: #666666;margin-top: 12rpx;font-size: 24rpx;">
					选择团队成员，经本人和店铺同意即可成为商家合伙人
				</view>
			</view>
			<view class="" style="font-size: 0;margin-left: 50rpx;">
				<image style="width: 14rpx;height: 20rpx;" src="./static/8.png" mode=""></image>
			</view>
		</view>
		<view v-if="identity!=3&&(identity==4||identity==5)" class="flex align-center" @click="goJoin"
			style="background: #F4F5F9;border-radius: 16rpx 16rpx 16rpx 16rpx;margin: 0 32rpx;margin-top: 40rpx;padding: 32rpx 40rpx;">
			<view class="" style="font-size: 0;margin-right: 40rpx;">
				<image style="width: 60rpx;height: 60rpx;" src="./static/3.png" mode=""></image>
			</view>
			<view class="flex-1">
				<view class="" style="font-size: 32rpx;font-weight: 500;color: #000000;">
					成为店铺合伙人
				</view>
				<view class="" style="color: #666666;margin-top: 12rpx;font-size: 24rpx;">
					选择平台店铺，本人申请需店铺同意即可成为商家合伙人
				</view>
			</view>
			<view class="" style="font-size: 0;margin-left: 50rpx;">
				<image style="width: 14rpx;height: 20rpx;" src="./static/8.png" mode=""></image>
			</view>
		</view>
		<view class="" @click="goBack" style="font-size: 0;position: fixed;left: 330rpx;bottom: 120rpx;">
			<image style="width: 88rpx;height: 88rpx;" src="static/7.png" mode=""></image>
		</view>
		<uni-popup ref="popup" background-color="#fff">
			<view class="popup_box flex">
				<view class="fengxiang_weima" @click="download">
					<view class="weima_image">
						<image class="w100 h100" src="/pages/filePages/static/fxewm.png" mode=""></image>
					</view>
					<view class="weima_txt s28 family f500 txtali">
						分享邀请码
					</view>
				</view>
				<view class="fengxiang_weima">
					<button open-type="share" :plain="true"
						style="background-color: transparent;border: none; padding: 0;">
						<view class="weima_image">
							<image class="w100 h100" src="./static/4.png" mode=""></image>
						</view>
						<view class="weima_txt s28 family f500 txtali" style="margin-top: 10rpx;">
							分享邀请链接
						</view>
					</button>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				uid: 0,
				userName: '',
				yqm:'',
				identity:3,// 1=注册会员，2=返利会员，3=商家职员，4=城市合伙人，5=店铺合伙人
			}
		},
		onLoad() {
			this.uid = uni.getStorageSync('userInfo').id;
			this.userName = uni.getStorageSync('userInfo').nickname;
			this.yqm = uni.getStorageSync('userInfo').invite_code;
			this.getMemberData();
		},
		onShareAppMessage(res) {
			if (res.from === 'button') { // 来自页面内分享按钮
				return false
			}
			return {
				title: `${this.userName}邀请您，一起成为荟云街平台合伙人！帮卖享分成！`,
				path: '/pages/filePages/helpSell/helpSell?uid=' + this.uid+'&yqm='+this.yqm,
				imageUrl: './static/share.jpg'
			}
		},
		methods: {
			// 商家职员不显示，成为店铺合伙人按钮
			getMemberData() {
				let that = this
				that.$request({
					url: 'member/getInfo',
					method: 'POST'
				}).then(res => {
					if (res.statusCode == 200) {
						this.identity = res.data.data.identity;
					}
				})
			},
			//返回
			goBack(){
				uni.navigateBack({
					delta:1
				})
			},
			//邀请店铺合伙人
			goInvite(){
				uni.navigateTo({
					url:'/pages/schedule/invitePartners'
				})
			},
			//加入店铺成为合伙人
			goJoin(){
				uni.navigateTo({
					url:'/pages/schedule/joinStore'
				})
			},
			//点击列表
			clickList() {
				this.$refs.popup.open('bottom')
			},
			// 下载邀请码
			download() {
				let that = this
				that.$request({
					url: 'share/getqrcode',
					method: 'POST',
					data: {
						invite_code: uni.getStorageSync('userInfo').invite_code
					}
				}).then(res => {
					uni.showLoading({
						title: '下载中...'
					});
					uni.downloadFile({
						url: res.data.data.code,
						success: (res) => {
							if (res.statusCode === 200) {
								uni.saveImageToPhotosAlbum({
									filePath: res.tempFilePath,
									success: function() {
										uni.showToast({
											title: '下载完成',
											icon: "success",
											duration: 2000
										})
									},
									fail: (error) => {
										uni.hideLoading()
										uni.showToast({
											title: '您已拒绝了访问相册',
											icon: "none",
											duration: 2000
										})
									}
								})
							}
						},
						fail:res=>{
							return false
						}
					});
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.flex {
		display: flex;
	}

	.flex-1 {
		flex: 1;
	}

	.align-center {
		align-items: center;
	}

	.justify-center {
		justify-content: center;
	}

	.justify-between {
		justify-content: space-between;
	}

	/* 分享弹窗 */
	.popup_box {
		width: 750upx;
		height: 360upx;
		background: #FFFFFF;
		border-radius: 48upx 48upx 0upx 0upx;
		overflow: hidden;

		.fengxiang_weima {
			width: 168upx;
			margin-top: 106upx;
			margin-left: 32upx;

			/deep/ button {
				width: 220upx;
				border: 1upx solid #FFFFFF;
			}

			.weima_image {
				width: 88upx;
				height: 88upx;
				margin: 0 auto;
			}

			.weima_txt {
				color: #333333;
				margin-top: 26upx;
			}
		}
	}
</style>
